package Odinote::OpenFile;

use strict;
use warnings;

use Gtk2;

my $self;
my $notebook;

sub _init
{
  shift;
  $self = shift;
  my $ff1 = Gtk2::FileFilter->new;
  $ff1->set_name("Odinote Files");
  $ff1->add_pattern("*.odin");
  my $ff2 = Gtk2::FileFilter->new;
  $ff2->set_name("TeX Files");
  $ff2->add_mime_type("text/x-tex");
  my $ff3 = Gtk2::FileFilter->new;
  $ff3->set_name("All Files");
  $ff3->add_pattern("*");
  $self->add_filter($ff1);
  $self->add_filter($ff2);
  $self->add_filter($ff3);
}

sub open
{
  $self->show;
}

sub cancel
{
  print "Open file cancelled.\n";
  hide($self);
}

sub choose
{
  print "File chosen.\n";
  hide($self);
  foreach my $docname ($self->get_filenames())
  {
    my $doc = Odinote::Document->new($docname);
    $doc->open;
  }
  #my $doc = Odinote::Document->new($self->get_filename);
  #$doc->open;
}

sub hide
{
  $self->hide;
}

1;
